package com.lagou.blog.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lagou.blog.entity.Article;
import com.lagou.blog.entity.BaseQuery;
import com.lagou.blog.mapper.ArticleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BlogService {
    @Autowired
    private ArticleMapper articleMapper;

    public IPage<Article> selectPage(BaseQuery query) {
        IPage<Article> page = new Page<>();
        page.setTotal(this.articleMapper.selectCount());
        page.setRecords(this.articleMapper.selectPage(query));
        return page;
    }
}
